<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        a,span{
            display: block;
            float: left;
        }
        a{
            width: 60%;
            height: 400px;
            background-color: red;
        }
        span{
            width: 30%;
            height: 50px;
        }
    </style>
</head>
<body>
    <a href="http://www.runoob.com">菜鸟网络</a>
    <span>X:<input type="text" class="xpos" /></span>
    <span>Y:<input type="text" class="ypos" /></span>
    <script>
        document.oncontextmenu = function(abc){
            console.log(abc);
            abc.preventDefault();//阻止默认行为
            return false;//取消默认行为
        }
        document.querySelector("a").onmousemove = function(eve){
            console.log(eve);
            console.log(eve.x);
            console.log(eve.y);
            document.querySelector(".xpos").value = eve.x;
            document.querySelector(".ypos").value = eve.y;
            eve.preventDefault();//阻止超链接的默认跳转
        };

        document.querySelector("a").onclick = function(eve){
            document.querySelector("a").onmousemove = null;
            eve.preventDefault();//阻止超链接的默认跳转
        }
    </script>
</body>
</html>